<template>
  <div class="dashboard-container">
    <header class="dashboard-header">
      <h1>智能教学助手</h1>
      <div class="user-info">
        <span>欢迎, {{ teacherName }}</span>
        <button @click="logout" class="logout-btn">退出登录</button>
      </div>
    </header>
    
    <div class="dashboard-content">
      <div class="card-container">
        <div class="card" @click="navigateTo('/design')">
          <div class="card-icon">📚</div>
          <h3>教学计划</h3>
          <p>创建和管理课程计划</p>
        </div>
        
        <div class="card" @click="navigateTo('/homework')">
          <div class="card-icon">📝</div>
          <h3>习题库</h3>
          <p>生成和管理练习题</p>
        </div>
        
        <div class="card" @click="navigateTo('/resources')">
          <div class="card-icon">🎬</div>
          <h3>教学资源</h3>
          <p>查看和管理教学资源</p>
        </div>
        
        <div class="card" @click="navigateTo('/study/analysis')">
          <div class="card-icon">📊</div>
          <h3>学情分析</h3>
          <p>智能分析学生学习情况</p>
        </div>
        
        <div class="card" @click="navigateTo('/profile')">
          <div class="card-icon">⚙️</div>
          <h3>个人设置</h3>
          <p>管理个人信息和账号设置</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { ref, onMounted } from 'vue';
import { useRouter } from 'vue-router';

export default {
  name: 'DashboardView',
  setup() {
    const router = useRouter();
    const teacherName = ref('');
    
    onMounted(() => {
      // 从本地存储获取教师信息
      teacherName.value = localStorage.getItem('teacherName') || '教师';
    });
    
    const navigateTo = (path) => {
      router.push(path);
    };
    
    const logout = () => {
      // 清除本地存储的登录信息
      localStorage.removeItem('token');
      localStorage.removeItem('teacherId');
      localStorage.removeItem('teacherName');
      
      // 跳转到登录页
      router.push('/login');
    };
    
    return {
      teacherName,
      navigateTo,
      logout
    };
  }
};
</script>

<style scoped>
.dashboard-container {
  min-height: 100vh;
  background-color: #f5f7fa;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background-color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dashboard-header h1 {
  margin: 0;
  font-size: 24px;
  color: #1890ff;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logout-btn {
  background-color: transparent;
  border: 1px solid #1890ff;
  color: #1890ff;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
}

.logout-btn:hover {
  background-color: #1890ff;
  color: white;
}

.dashboard-content {
  padding: 24px;
}

.card-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.card {
  background-color: white;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-icon {
  font-size: 36px;
  margin-bottom: 16px;
}

.card h3 {
  margin: 0 0 8px 0;
  color: #333;
}

.card p {
  margin: 0;
  color: #666;
}
</style> 